<?php
/**
 * User: Hunman
 * Date: 14.07.13
 * Time: 15:17
 */
class Controller_Category extends Controller_Default
{
    function __construct($categoryId, $filter)
    {
        $categoryId = (int)$categoryId;
        $categoryId != 0 ? $this->getCategory($categoryId, $filter) : $this->getAllCategory();
    }

    private function getCategory($categoryId, $filter)
    {
        $categoryId = (int)$categoryId;
        $OrderBy = $this->filter($filter);
        $mode = new Model_Category();
        $categoryInfo = $mode->getCategoryData($categoryId, $OrderBy);

        $this->ordreNamePrice=$OrderBy[oNP];
        $this->limitBegin=$OrderBy[lB];
        $this->limitCount=$OrderBy[lC];

        preg_match_all("/([A-Z-a-z]+\/\d+)/", $_SERVER['REQUEST_URI'], $uriArray);
        foreach($uriArray[0] as $uri)
        {
            $this->uriNoFilter=$uri;
        }

        $view = new View_Category();
        $view->pageContent = $categoryInfo;
        $this->view = $view->view();
        $this->pagination(get_class(), $categoryId);
        $this->render("mainPage.twig");
    }

    private function getAllCategory()
    {
        echo "Define";
    }
}